package com.example.jetpacktest.lifecycle

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.example.jetpacktest.R

class MyLifecycleActivity: AppCompatActivity() {

    private lateinit var myLocationListener: MyLocationListener

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_my_life_cycle)
        myLocationListener = MyLocationListener(this, lifecycle){

        }

        lifecycle.addObserver(myLocationListener) //这句话千万记得要加，否则没有效果
    }

    override fun onResume() {
        super.onResume()
        myLocationListener.fun1()
    }

}